/*
 *  I2W_Email.h
 *
 *  Created by Pat Long (plong0) on 03/03/10.
 *  Copyright 2010 Tangible Interaction Inc. All rights reserved.
 *
 */
#ifndef _OFX_IMAGE2WEB_SERVICE_EMAIL
#define _OFX_IMAGE2WEB_SERVICE_EMAIL

#include "Image2WebService.h"
#include "ofxMailUtils.h"
#include "ofxTI_Utils.h"

#define I2W_EMAIL_DEFAULT_TIMEOUT -1

extern int currentLogLevel;

/** IMPORTANT NOTE: This email module requires a modified (ofxMailUtils_plong0) version of the ofxMailUtils addon.
 
 You may download the modified (ofxMailUtils_plong0) version through the following sources on Tangible Interaction's Google Code Project page.
 
 Direct Zip Archive (latest stable release):
	http://tiof.googlecode.com/files/ofxMailUtils_plong0.zip
 
 SVN repository (dev version):
	svn checkout http://tiof.googlecode.com/svn/trunk/ tiof-read-only
 
 */

class I2W_Email : public Image2WebService{
protected:
	ofxSmtpClientUtils* smtp;
	ofxMailMessage* message;
	int timeout;
	
	bool validEmail(string emailAddress);
	
	virtual bool checkParams(map<string,string> params);
	
public:
	I2W_Email();
	~I2W_Email();
	
	void setTimeout(int timeout=I2W_EMAIL_DEFAULT_TIMEOUT);
	
	bool connectSMTP(string smtp_server, int smtpPort, string smtp_username, string smtp_password);
	
	virtual void update();
	virtual bool postImage(ofxImage image, map<string,string> params);
};

#endif
